package org.mebusw.davincicode.unittest;

import java.util.ArrayList;
import org.mebusw.davincicode.CardPoolManager;
import org.mebusw.davincicode.vo.DavinciCard;

import junit.framework.Assert;
import junit.framework.TestCase;

public class TestCardPoolManager extends TestCase {

	private CardPoolManager op = null;

	public TestCardPoolManager(String name) {
		super(name);
	}

	protected void setUp() throws Exception {
		super.setUp();
		op = new CardPoolManager(new ArrayList<DavinciCard>());
		
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public void testRandGet_null() {
		op.clear();
		Assert.assertNull(op.randTake());

	}

	public void testRandGet_not_null() {
		DavinciCard card;

		op.initPool(true);
		card = op.randTake();
		
		Assert.assertNotNull(card);
		Assert.assertEquals(DavinciCard.IN_POOL, card.getOwner());
		// System.out.println(card.getValue() + card.getCardId());
		Assert.assertEquals(25, op.size());

		card = op.randTake();
		Assert.assertNotNull(card);
		// System.out.println(card.getValue() + card.getCardId());
		Assert.assertEquals(24, op.size());

		card = op.randTake();
		Assert.assertNotNull(card);
		// System.out.println(card.getValue() + card.getCardId());
		Assert.assertEquals(23, op.size());
	}
}
